<template>
	<view class="userbank">
		<view class="info">
			<view class="title">
				银行信息
			</view>
			<view class="info_input">
				<input type="text" placeholder="开户银行" v-model="bank_name" />
			</view>
			<view class="info_input">
				<input type="text" placeholder="开户支行" v-model="bank_open" />
			</view>
			<view class="info_input">
				<input type="text" placeholder="银行卡号" v-model="bank_num" />
			</view>
			<view class="info_input">
				<input type="text" placeholder="开户姓名" v-model="bank_user" />
			</view>
		</view>
		<view class="info">
			<view class="title">
				微信收款码
			</view>
			<view class="fireimg" v-if="is_show">
				<fjjImages :pageImgList="wximg" @getwximgurl="getwximgurl" :type="geturl[0]" :imgCount="1"
					@addImg="editParkImg" @deleteImg="deleteImg" :imgurl='wechat_code'></fjjImages>
			</view>
		</view>


		<view class="info">
			<view class="title">
				支付宝收款码
			</view>

			<view class="fireimg" v-if="is_show">
				<fjj-images :pageImgList="zfbimg" @getzfbimgurl="getzfbimgurl" :type="geturl[1]" :imgCount="1"
					@addImg="editParkImg" @deleteImg="deleteImg"></fjj-images>
			</view>
		</view>
		<view class="btn" @click="GetUserBank()">
			保存并使用
		</view>
	</view>
</template>

<script>
	import {
		UserBank,
		GetUserBank
	} from '../../api/api.js'
	// import fjjImages from '../../components/fjj-images/fjj-images.vue';
	export default {
		// components: {
		// 	fjjImages
		// },
		data() {
			return {
				geturl: ['getwximgurl', 'getzfbimgurl'],
				zfbimg: [],
				wximg: [],
				bank_name: '',
				bank_open: '',
				bank_user: '',
				bank_num: '',
				wechat_code: '',
				ali_code: '',
				wx_img: '',
				zfb_img: '',
				is_show:false

			}
		},
		onLoad() {
			this.UserBank()
		},
		methods: {
			UserBank() {
				UserBank().then(res => {
					console.log(res)
					this.bank_name = res.data.bank_name
					this.bank_num = res.data.bank_num
					this.bank_open = res.data.bank_open
					this.bank_user = res.data.bank_user
					this.wx_img = res.data.wechat_code
					this.zfbimg[0] = this.websiteUrl + res.data.ali_code
					this.wximg[0] = this.websiteUrl + res.data.wechat_code
					this.zfb_img = res.data.ali_code
					this.is_show = true
				})
			},
			GetUserBank() {
				GetUserBank({
					bank_name: this.bank_name,
					bank_open: this.bank_open,
					bank_user: this.bank_user,
					bank_num: this.bank_num,
					wechat_code: this.wx_img,
					ali_code: this.zfb_img
				}).then(res => {
					console.log(res)
					if (res.status == 1) {
						 uni.showToast({
						 	title: res.message,
						 	icon: 'none'
						 })
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
				})
			},
			getwximgurl(e) {
				this.wx_img = e[0]
				console.log(e)
			},
			getzfbimgurl(e) {
				this.zfb_img = e[0]
				console.log(e)
			},
			editParkImg(currentTempFilePath) {},
			deleteImg(index) {},
		}
	}
</script>

<style lang="scss">
	.info {
		.title {
			padding: 5%;
			color: #999;
		}

		.info_input {
			background: #FFFFFF;
			padding: 5%;
			margin-bottom: 20rpx;
		}
	}
</style>
